﻿using System;
using System.Linq;
using GdHotel.Data.Interfaces;

namespace GdHotel.Data.Repositories
{
    public class MessagesRepository : IMessagesRepository
    {
        private GdHotelEntities entities = new GdHotelEntities();

        public IQueryable<Message> FindAll()
        {
            return entities.Messages.AsQueryable();
        }

        public IQueryable<Message> FindAllByLang(Language lang)
        {
            return entities.Messages.AsQueryable();
        }

        public Message GetById(Int32 id)
        {
            return entities.Messages.SingleOrDefault(message => message.Id == id);
        }

        public void Insert(Message message)
        {
            entities.AddToMessages(message);
        }

        public void Delete(Message message)
        {
            entities.Messages.DeleteObject(message);
        }

        public void Save()
        {
            entities.SaveChanges();
        }

        public void Dispose()
        {
            entities.Dispose();
        }
    }
}
